﻿<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, user-scalable=no">
<link rel="stylesheet" href="jquery-mobile/jquery.mobile.min.css" />
<script type="text/javascript" src="jquery-mobile/jquery.js"></script>
<script type="text/javascript" src="jquery-mobile/jquery.mobile.min.js"></script>
<script type="text/javascript" src="jquery-mobile/iscroll.js"></script>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="unzipfolder.js"></script> 
<script type="text/javascript" src="changeactivity.js"></script> 
<script type="text/javascript">
var myscroll;
function loaded(){
	myScroll = new iScroll('wrapper', { checkDOMChanges: true ,  hScrollbar: false, vScrollbar: false });	
	/*setInterval(function () {
		if (myScroll.isReady())
			document.getElementById('thelist').innerHTML += '<li>new row</li>';
	}, 2000);*/
	 }
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
window.addEventListener("DOMContentLoaded",loaded,false);
function changetopage(url){
	window.location = url;
	}
function exit(){
	window.close();
	document.write('<n>');
	}
$(document).ready(function() {
    $("#rankListBtn").tap(
	function(){
		//alert("1");
		//loadXMLDoc('http://172.19.100.140:8080/Bgame/ranklist.txt',load_ranklist);
		//alert("2");
		document.getElementById('top').style.display='block';
		document.getElementById('ranklist').style.display='block';
		
	});
});
$(document).ready(function() {
    $("#gameTypeBtn").tap(
	function(){
		document.getElementById('top').style.display='block';
		document.getElementById('gametype').style.display='block';
	});
});
$(document).ready(function() {
    $(".paihb").tap(
	function(){
		document.getElementById('top').style.display='none';
		document.getElementById('ranklist').style.display='none';
		document.getElementById('gametype').style.display='none';
	});
});
document.getElementById('top').addEventListener("touchstart",
function(){
		document.getElementById('top').style.display='none';
		document.getElementById('ranklist').style.display='none';
		document.getElementById('gametype').style.display='none';
	},false);
	
/////Ajax get list from server ///////////////////////
var xmlhttp;
function loadXMLDoc(url,id)
{
	//alert("i am in !");
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for Firefox, Opera, IE7, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=function()
  {
  	if (xmlhttp.readyState == 4) {// 4 = "loaded"
		if (xmlhttp.status == 200) {// 200 = "OK"
			document.getElementById(id).innerHTML = xmlhttp.responseText;
			getGameId();
			
			$("#"+id).listview("refresh");
		}
		else 
			alert("加载超时，请稍后重试！");
	}
  }
  //xmlhttp.open("GET","http://172.19.100.140:8080/Bgame/gamelist.txt",true);
 //alert("11");
  xmlhttp.open("GET",url,true);
  xmlhttp.setRequestHeader("Cache-Control","no-cache");
  //alert("12");
  //xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  //xmlhttp.open("GET","/sdcard/rdsdcardfile.txt",true);
  xmlhttp.send(null);
 //alert("13");
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}
///////////////////end of get list from server ///////////////////
function getGameId(){
  var ul = document.getElementById('gamelist');
  var lis = ul.getElementsByTagName('li');
  for(var i=0;i<lis.length;i++){
       lis[i].onclick = function(){
       //alert(this.id);
	   var gameID = this.id;
	   var url = 'http://172.19.100.140:8080/JsGamePlatform/'+gameID+'.zip';
		var filePath = '/sdcard/Bgame/'+gameID+'.zip';
		
		//alert(url);
		//alert(filePath);
		
		var fileTransfer = new FileTransfer();
		fileTransfer.download(
		    url,
		    filePath,
		    function(entry) {
		        //alert("download complete: " + entry.fullPath);
				UnZipFolders.unzip('/sdcard/Bgame/'+gameID+'.zip','/sdcard/Bgame/',    
				function(r){
					//alert("successed!");
					ChangeActivity.jump(gameID,
					function(r){
					//alert("successed!");					
					},    
					function(e){
						alert("failure!");
					}    
					); 
					//alert('/sdcard/Bgame/'+gameID+'.zip');
				},    
				function(e){
					alert("failure!");
				}    
				); 
		    },
		    function(error) {
		        alert("download error source " + error.source);
		        alert("download error target " + error.target);
		        alert("upload error code" + error.code);
		    }
		);
		   
       }
  } 
 }
 //////////////////////////////end of start a game////////////////////////

</script>
<style type="text/css">
#wrapper {
	position:absolute;
	top:20px;
	bottom:50px;
	left:0;
	width:100%;
}
.topdiv{
		display: none;
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index:1001;
		}
.belowdiv {
	display: none;
	position:absolute;
	top: 35px;
	left: 0%;
	width: 50%;
	height: 400px;
	padding: 30px 10px;
	background-image:url(images/ranklist.png);
	background-repeat:no-repeat;
	z-index:1002;
	overflow: auto;
}
.gametype {
	display: none;
	position: absolute;
	top:35px;
	right:0%;
	width: 50%;
	height: 400px;
	padding: 30px 10px;
	background-image:url(images/gametype.png);
	background-repeat:no-repeat;
	z-index:1002;
	overflow: auto;
}

</style>
</head>
<body>
<div data-role="page" id="home" >
  <div data-role="header" data-theme="e" data-position="fixed">
    <h1>北纬游戏平台</h1>
  </div>
  <div data-role="content">
    <ul data-role="listview" data-inset="true" data-theme="c">
      <li><a href="#helpcenter">帮助中心</a></li>
      <li><a href="#mycenter">我的帐号</a></li>
      <li><a href="#aboutus">关于我们</a></li>
      <li><a href="#">退出</a></li>
    </ul>
  </div>
  <div data-role="footer" data-position="fixed" data-iconpos="top" data-id="myfooter">
    <div data-role="navbar">
      <ul>
        <li><a href="#home" data-icon="home" data-theme="e" data-transition="none">首页</a></li>
        <li><a href="#games" data-icon="grid" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/gamelist.txt?t=' + Math.random(),'gamelist')">游戏大厅</a></li>
        <li><a href="#favorite" data-icon="star" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/myClectionlist.txt?t=' + Math.random(),'myClection')">我的收藏</a></li>
        <li><a href="#update"data-icon="gear" data-theme="e" data-transition="none">自动更新</a></li>
      </ul>
    </div>
    <!-- /navbar --> 
  </div>
  <!-- /footer --> 
</div>
<!--end of home-->

<div data-role="page" id="games">
  <div data-role="header" data-theme="e" data-position="fixed">
  	<a href="javascript:void(0)" data-icon="arrow-u" data-theme="e" id="rankListBtn">排行榜</a>
    <h1>游戏大厅</h1>
    <a href="javascript:void(0)" data-icon="info" data-theme="e" id="gameTypeBtn">分类</a>                
  </div>
  <div id="top" class="topdiv">
    	<div id="ranklist" class="belowdiv">
        	<ul data-role="listview" data-inset="true" data-theme="c">
            	<li><a href = "javascript:void(0)" class="paihb">本周点击排行榜</a></li>
                <li><a href = "javascript:void(0)" class="paihb">最高积分排行榜</a></li>
                <li><a href = "javascript:void(0)" class="paihb">游戏记录排行榜</a></li>    		
            </ul>
        </div>
        <div id="gametype" class="gametype">
        	<ul data-role="listview" data-inset="true" data-theme="c">
            	<li><a href = "javascript:void(0)" class="paihb">迷宫类</a></li>
                <li><a href = "javascript:void(0)" class="paihb">重力感应类</a></li>
                <li><a href = "javascript:void(0)" class="paihb">其它</a></li>    		
            </ul>
        </div>
        </div>
 <div id="wrapper">
 	<div id="scroller">
      <div data-role="content">
       	
      	<div data-role="fieldcontain" data-inset="false">
     		<input type="search" name="" id="search" value="."/>
		</div>
        <ul id="gamelist" data-role="listview" data-inset="false" data-theme="c" data-count-theme="e" data-split-icon="star" data-split-theme="e">
          <!--<li><a href="http://172.19.100.140:8080/Bgame/Tetris/Tetris.html">俄罗斯方块</a></li>-->
        
		</ul>
  		</div>
  	</div>
  </div>
  <div data-role="footer" data-position="fixed" data-id="myfooter">
    <div data-role="navbar">
      <ul>
        <li><a href="#home" data-icon="home" data-theme="e" data-transition="none">首页</a></li>
        <li><a href="#games" data-icon="grid" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/gamelist.txt?t=' + Math.random(),'gamelist')">游戏大厅</a></li>
        <li><a href="#favorite" data-icon="star" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/myClectionlist.txt?t=' + Math.random(),'myClection')">我的收藏</a></li>
        <li><a href="#update"data-icon="gear" data-theme="e" data-transition="none">自动更新</a></li>
      </ul>
    </div>
    <!-- /navbar --> 
  </div>
</div>
<!--end of games-->

<div data-role="page" id="favorite">
  <div data-role="header" data-theme="e">
    <h1>我的收藏</h1>
  </div>
  <div data-role="content">
     <ul id="myClection" data-role="listview" data-inset="false" data-split-icon="delete" data-split-theme="e" data-theme="c">
          <!--<li><a href="http://172.19.100.140:8080/Bgame/Tetris/Tetris.html">俄罗斯方块</a></li>-->
         
        </ul>
  </div>
  <div data-role="footer" data-position="fixed" data-id="myfooter">
    <div data-role="navbar">
      <ul>
        <li><a href="#home" data-icon="home" data-theme="e" data-transition="none">首页</a></li>
        <li><a href="#games" data-icon="grid" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/gamelist.txt?t=' + Math.random(),'gamelist')">游戏大厅</a></li>
        <li><a href="#favorite" data-icon="star" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/myClectionlist.txt?t=' + Math.random(),'myClection')">我的收藏</a></li>
        <li><a href="#update"data-icon="gear" data-theme="e" data-transition="none">自动更新</a></li>
      </ul>
    </div>
    <!-- /navbar --> 
  </div>
</div>
<!--end of my favorite-->

<div data-role="page" id="update">
  <div data-role="header" data-theme="e">
    <h1>自动更新</h1>
  </div>
  <div data-role="content">
    <ul data-role="listview" data-inset="true" data-theme="c">
      <li><a href="#">检查更新</a></li>
    </ul>
  </div>
  <div data-role="footer" data-position="fixed" data-id="myfooter">
    <div data-role="navbar">
      <ul>
        <li><a href="#home" data-icon="home" data-theme="e" data-transition="none">首页</a></li>
        <li><a href="#games" data-icon="grid" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/gamelist.txt?t=' + Math.random(),'gamelist')">游戏大厅</a></li>
        <li><a href="#favorite" data-icon="star" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/myClectionlist.txt?t=' + Math.random(),'myClection')">我的收藏</a></li>
        <li><a href="#update"data-icon="gear" data-theme="e" data-transition="none">自动更新</a></li>
      </ul>
    </div>
    <!-- /navbar --> 
  </div>
</div>
<!--end of update-->

<div data-role="page" id="helpcenter">
  <div data-role="header" data-theme="e">
    <h1>帮助中心</h1>
  </div>
  <div data-role="content">
      帮助中心
  </div>
  <div data-role="footer" data-position="fixed" data-id="myfooter">
    <div data-role="navbar">
      <ul>
        <li><a href="#home" data-icon="home" data-theme="e" data-transition="none">首页</a></li>
        <li><a href="#games" data-icon="grid" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/gamelist.txt?t=' + Math.random(),'gamelist')">游戏大厅</a></li>
        <li><a href="#favorite" data-icon="star" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/myClectionlist.txt?t=' + Math.random(),'myClection')">我的收藏</a></li>
        <li><a href="#update"data-icon="gear" data-theme="e" data-transition="none">自动更新</a></li>
      </ul>
    </div>
    <!-- /navbar --> 
  </div>
</div>
<!--end of update-->

<div data-role="page" id="mycenter">
  <div data-role="header" data-theme="e">
    <h1>我的帐号</h1>
  </div>
  <div data-role="content">
     我的帐号
  </div>
  <div data-role="footer" data-position="fixed" data-id="myfooter">
    <div data-role="navbar">
      <ul>
        <li><a href="#home" data-icon="home" data-theme="e" data-transition="none">首页</a></li>
        <li><a href="#games" data-icon="grid" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/gamelist.txt?t=' + Math.random(),'gamelist')">游戏大厅</a></li>
        <li><a href="#favorite" data-icon="star" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/myClectionlist.txt?t=' + Math.random(),'myClection')">我的收藏</a></li>
        <li><a href="#update"data-icon="gear" data-theme="e" data-transition="none">自动更新</a></li>
      </ul>
    </div>
    <!-- /navbar --> 
  </div>
</div>
<!--end of update-->

<div data-role="page" id="aboutus">
  <div data-role="header" data-theme="e">
    <h1>关于我们</h1>
  </div>
  <div data-role="content">
      关于我们
  </div>
  <div data-role="footer" data-position="fixed" data-id="myfooter">
    <div data-role="navbar">
      <ul>
        <li><a href="#home" data-icon="home" data-theme="e" data-transition="none">首页</a></li>
        <li><a href="#games" data-icon="grid" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/gamelist.txt?t=' + Math.random(),'gamelist')">游戏大厅</a></li>
        <li><a href="#favorite" data-icon="star" data-theme="e" data-transition="none" ontouchstart="loadXMLDoc('http://172.19.100.140:8080/Bgame/myClectionlist.txt?t=' + Math.random(),'myClection')">我的收藏</a></li>
        <li><a href="#update"data-icon="gear" data-theme="e" data-transition="none">自动更新</a></li>
      </ul>
    </div>
    <!-- /navbar --> 
  </div>
</div>
<!--end of update-->
</body>
</html>
